(function () {
    angular.module('app')
        .component('xxSearchDrug',{
            templateUrl:'./app/user/search-drug/search-drug.html',
            controller:ctrl
        });

    function ctrl($scope,$state,SearchDrugFactory) {

        $scope.disease = '';
        $scope.drugList = [];
        function getDrugByDisease(body){
            function cb(err, res) {
                //console.log(err,res);
                if(!err) {
                    $scope.drugList = res['res'];
                }
            }
            SearchDrugFactory.getDrugByDisease(body, cb);
        }
        getDrugByDisease($scope.disease);

        $scope.drugInfo = function (drugId) {
            $state.go('user.drug-info',{drugId:drugId});
        };


    }
})();
